
//
//  GetUserHistoryTask.m
//  ZooNgonDoiOS
//
//  Created by Anh Jun Linh Tinh on 7/5/12.
//  Copyright (c) 2012 Personal. All rights reserved.
//

#import "GetUserHistoryTask.h"

@implementation GetUserHistoryTask

-(id)initWithUserId:(int)userId{
    [self initWithUserId:userId limit:0];
    return self;   
}

-(id)initWithUserId:(int)userId limit:(int)limit{
    self = [super init];
    if(self){
        _userId = userId;
        _limit = limit;
    }
    return self;
}

-(void)doExecute{
    NSMutableArray *arrayKeys = [[NSMutableArray alloc] init];
    NSMutableArray *arrayValues = [[NSMutableArray alloc] init];
    
    [arrayKeys addObject:@"user_id"];
    NSString* strUserId = [NSString stringWithFormat:@"%i", _userId];
    [arrayValues addObject:strUserId];
    
    if(_limit > 0){
      NSString* strLimit = [NSString stringWithFormat:@"%i", _limit];
      [arrayKeys addObject:@"limit"];
      [arrayValues addObject:strLimit]; 
    }
    
    NSDictionary *params = [NSDictionary dictionaryWithObjects:arrayValues forKeys:arrayKeys];
    [[RKObjectManager sharedManager].client get:@"/user/history" queryParameters:params delegate:self];
    
}

-(void)request:(RKRequest *)request didFailLoadWithError:(NSError *)error{
    
}

-(void)request:(RKRequest *)request didLoadResponse:(RKResponse *)response{
    
}
@end
